<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/3/23
  Time: 11:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>通知管理</title>
    <script type="text/javascript" src="../script/jquery-3.2.1.js"></script>
    <link href="../css/homePage.css" rel="stylesheet" type="text/css"/>
    <script src="../script/commonFunction.js" type="text/javascript"></script>
    <style type="text/css">
        #main_body {
            background-image: url("../images/bg90.jpg");
        }

        #admin_menu_div {
            padding-left: 18%;
            overflow: hidden;
            margin-top: -20px;
            border-bottom: double 2px #bbc;
        }

        #admin_menu_div_ul {
            overflow: hidden;
        }

        #admin_menu_div_ul h4 {
            position: relative;
            float: left;
            margin-right: 10%;
            border-color: #ffd8d7;
        }

        #admin_main_div div {
            width: 700px;
            margin: 30px auto;
        }

        table {
            background-color: rgba(0, 130, 230, 0.6);
        }

        table thead th {
            width: 99px;
        }

        tbody td {
            text-align: center;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            $("#admin_main_div").children().hide();

            tick();

            $("#admin_interview_message").click(function () {
                switchoverColor(this, $("#not_interview_div"));
            });

            $("#admin_train_message").click(function () {
                switchoverColor(this, $("#all_trains_div"));
            });

            $("#apply_go_back").click(function () {
                if (confirm("你确定要返回首页吗！"))
                    window.location.href = "../admin/managePageJump";
            });

            $(".look_resume").click(function () {
                var name = $(this).text();
                var uId = $(this).find("input[name=uId]").val();
                var aId = $(this).find("input[name=aId]").val();
                console.log("uId = " + uId + "************aId = " + aId + "-----------name = " + name);
                $.post("../admin/getResume",
                    {"uId": uId},
                    function (data) {
                        $("#resume_name").html(data.realName);
                        $("#resume_age").html(data.age);
                        $("#resume_sex").html(data.sex);
                        $("#user_phone").html(data.user.phone);
                        $("#resume_education").html(data.education.education);
                        $("#resume_email").html(data.email);
                        $("#resume_position").html(data.position.section.section + " ").append(" " + data.position.position);
                        $("#resume_politicsStatus").html(data.politicsStatus.politics);
                        $("#resume_lastJop").html(data.lastJop);
                        $("#resume_experience").html(data.experience);
                        $("#resume_expectedSalary").html(data.expectedSalary);
                        $("#resume_hobbies").html(data.hobbies);
                    });
                $("#not_interview_div").hide();
                $("#resume_detail_div0").show();
            });

            $("#resume_detail_go_back").click(function () {
                $("#resume_detail_div0").hide();
                $("#not_interview_div").show();
            });

            $("#mark_read").click(function () {
                var tId = $(this).siblings("input[name=trainId]").val();
                $.post("../train/updateTrain",
                    {"id": tId},
                    function (data) {
                        if (data === 1)
                            $(this).parent().html("已读");
                        else
                            alert("标记失败！");
                    });
            });

            $(".employ_but").click(function () {
                var uId = $(this).siblings("input[name='uId']").val();
                var aId = $(this).siblings("input[name=aId]").val();
                var rId = $(this).siblings("input[name=rId]").val();
                var date = $(this).parent().siblings("td[class=view_date]").text();
                console.log("employ_but--uId = " + uId + "---aId = " + aId + "---viewDate = " + date + "---rId = " + rId);

                if (!confirm("您确定已经面试并继续操作吗？"))
                    return;
                var $level = $("#admin_choose_level");
                $level.find("input[name='uId']").val(uId);
                $level.find("input[name='aId']").val(aId);
                $level.find("input[name='rId']").val(aId);
                $("#not_interview_div").hide();
                $level.show();
            });

            $("#level_sub").click(function () {
                var uId = $(this).siblings("input[name=uId]").val();
                var aId = $(this).siblings("input[name=aId]").val();
                var rId = $(this).siblings("input[name=rId]").val();
                var level = $("#level").val();
                console.log("level-click=======uId = " + uId + "=======aId = " + aId + "=========level = " + level);
                $.post("../admin/addEmployee",
                    {"uId": uId, "aId": aId, "lId": level, "rId": rId},
                    function (data) {
                        if (data === 1)
                            alert("操作成功！请刷新页面！");
                        else
                            alert("操作失败！");
                        $("#admin_choose_level").hide();
                    });
            });

            $(".not_employ_but").click(function () {
                var uId = $(this).siblings("input[name='uId']").val();
                var aId = $(this).siblings("input[name='aId']").val();
                var date = $(this).parent().siblings("td[class=view_date]").text();
                console.log("employ_but--------uId = " + uId + "--------aId = " + aId + "------------viewDate = " + date);

                if (!confirm("您确定已经面试并继续操作吗？"))
                    return;
                $.post("../admin/notEmploy",
                    {"uId": uId, "aId": aId},
                    function (data) {
                        if (data === 1)
                            alert("操作成功！请刷新页面！");
                        else
                            alert("操作失败！");
                    });
            });
        })
    </script>
</head>
<body id="main_body">
<div id="welcome">
    <c:if test="${manager != null}">
        欢迎${manager.name }登录&nbsp;&nbsp;&nbsp;<a href="../logout.action">退出</a>
    </c:if>
    <c:if test="${manager == null }">
        <%response.sendRedirect("../admin/login.jsp");%>
    </c:if>
    <span id="showTime">本地时间：<span id="localtime"></span></span>
</div>
<div id="admin_menu_div">
    <ul id="admin_menu_div_ul">
        <h4>
            <li id="admin_interview_message">面试通知</li>
        </h4>
        <h4>
            <li id="admin_train_message">培训通知</li>
        </h4>
        <h4>
            <li id="apply_go_back">返回首页</li>
        </h4>
        <h4>
            <li id="quit">退出</li>
        </h4>
    </ul>
</div>
<div id="admin_main_div">

    <div id="not_interview_div">
        <table cellpadding="0" cellspacing="0" border="1px" id="not_interview_able">
            <thead>
            <tr>
                <th colspan="6">应聘信息</th>
            </tr>
            <tr>
                <th>编号</th>
                <th>投递人</th>
                <th>投递时间</th>
                <th>面试时间</th>
                <th id="interview_th" colspan="2">是否录用</th>
            </tr>
            </thead>
            <tbody>
            <c:if test="${empty applyNotInterview}">
                <tr>
                    <td colspan="6">还没有应聘消息</td>
                </tr>
            </c:if>
            <c:if test="${not empty applyNotInterview}">
                <c:forEach var="ani" items="${applyNotInterview}">
                    <tr>
                        <td>${ani.id}</td>
                        <td class="look_resume" style="cursor: pointer;color: blue;">
                            <input type="hidden" name="uId" value="${ani.resume.user.id}">
                            <input type="hidden" name="aId" value="${ani.id}">
                                ${ani.resume.realName}
                        </td>
                        <td>
                            <f:formatDate value="${ani.postTime}" pattern="yyyy-MM-dd"/>
                        </td>
                        <td class="view_date">
                            <f:formatDate value="${ani.interviewDate}" pattern="yyyy-MM-dd"/>
                        </td>
                        <td class="interview_td1">
                            <input type="hidden" name="uId" value="${ani.resume.user.id}">
                            <input type="hidden" name="aId" value="${ani.id}">
                            <input type="hidden" name="rId" value="${ani.resume.id}">
                            <input type="button" value="录用" class="employ_but">
                        </td>
                        <td class="interview_td0">
                            <input type="hidden" name="uId" value="${ani.resume.user.id}">
                            <input type="hidden" name="aId" value="${ani.id}">
                            <input type="button" value="不录用" class="not_employ_but">
                        </td>
                    </tr>
                </c:forEach>
            </c:if>
            </tbody>
        </table>
    </div>

    <div id="resume_detail_div0">
        <table cellspacing="1" cellpadding="1" border="solid 1px #000" id="resume_detail_table"
               style="background-color: rgba(0,130,230,0.6);">
            <thead>
            <tr>
                <th colspan="4"><p>简历详情</p></th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>真实姓名：</td>
                <td id="resume_name"></td>
                <td>性别：</td>
                <td id="resume_sex"></td>
            </tr>
            <tr>
                <td>年龄：</td>
                <td id="resume_age"></td>
                <td>学历：</td>
                <td id="resume_education"></td>
            </tr>
            <tr>
                <td>联系方式：</td>
                <td id="user_phone"></td>
                <td>e-mail：</td>
                <td id="resume_email"></td>
            </tr>
            <tr>
                <td>应聘职位：</td>
                <td id="resume_position"></td>
                <td>政治面貌：</td>
                <td id="resume_politicsStatus"></td>

            </tr>
            <tr>
                <td>上一份工作：</td>
                <td id="resume_lastJop"></td>
                <td>工作经验：</td>
                <td id="resume_experience"></td>
            </tr>
            <tr>
                <td>期望薪资：</td>
                <td id="resume_expectedSalary"></td>
                <td>兴趣爱好：</td>
                <td id="resume_hobbies"></td>
            </tr>
            </tbody>
            <tfoot>
            <tr>
                <td colspan="4" style="text-align: center">
                    <input type="button" class="resume_bu" id="resume_detail_go_back" value="返回">
                </td>
            </tr>
            </tfoot>
        </table>
    </div>

    <div id="all_trains_div">
        <table cellpadding="0" cellspacing="0" border="1px" id="myTable2">
            <thead>
            <tr>
                <th colspan="5">培训通知</th>
            </tr>
            <tr>
                <th>编号</th>
                <th>主题</th>
                <th>时间</th>
                <th>预计时长</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:if test="${empty trains}">
                <tr>
                    <td colspan="5">没有新的培训消息呦</td>
                </tr>
            </c:if>
            <c:if test="${not empty trains}">
                <c:forEach var="train" items="${trains}">
                    <tr>
                        <td>${train.id}</td>
                        <td>${train.details}</td>
                        <td><f:formatDate value="${train.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                        <td>${train.duration}</td>
                        <td style="text-align: center">
                            <c:if test="${train.looked == 1}">
                                已读
                            </c:if>
                            <c:if test="${train.looked == 0}">
                                <input name="trainId" value="${train.id}" type="hidden"/>
                                <input id="mark_read" type="button" value="标记已读">
                            </c:if>
                        </td>
                    </tr>
                </c:forEach>
            </c:if>
            </tbody>
        </table>
    </div>

    <div id="admin_choose_level">
        <div id="choose_level" style="width: 399px; margin: 10px auto">
            <label for="level">职级选择：</label>
            <select name="level_id" id="level">
                <c:forEach items="${levelList}" var="pl">
                    <option value="${pl.id}">${pl.id}</option>
                </c:forEach>
            </select>
            <input type="hidden" name="uId">
            <input type="hidden" name="aId">
            <input type="hidden" name="rId">
            <input type="button" id="level_sub" value="提交">
        </div>
    </div>
</div>

</body>
</html>
